package com.example.mapp.buildSql;

import com.example.entity.PointDefend;
import com.example.util.StringUtil;

/**
 * 查询积分
 */
public class PointDefendMappSql {
    /**
     *
     * 查询的SQL
     * findList
     * @param
     * @return
     */
    public String findList(PointDefend pointDefend){
        StringBuffer sb = new StringBuffer();
        sb.append(" select ");
        sb.append("  id AS id, ");
        sb.append("  (case when operation_type='0' then 'PC端' else 'APP端' end ) AS 'operationType', ");
        sb.append("  operation_content AS 'operationContent', ");
        sb.append("  operation_role AS 'operationRole', ");
        sb.append("  identification AS 'identification',");
        sb.append("  mark AS 'mark',");
        sb.append("  must_bean AS 'mustBean',");
        sb.append("  create_by AS 'createBy', ");
        sb.append("  create_date AS 'createDate', ");
        sb.append("  update_by AS 'updateBy', ");
        sb.append("  update_date AS 'updateDate'");
        sb.append("  from point_defend  where 1=1 ");


        if(pointDefend.getId() !=null){
            sb.append(" and id="+pointDefend.getId());
        }
        if(StringUtil.isNotBlank(pointDefend.getOperationType())){
            sb.append(" and operation_type='"+pointDefend.getOperationType()+"'");
        }
        if(StringUtil.isNotBlank(pointDefend.getIdentification())){
            sb.append(" and identification='"+pointDefend.getIdentification()+"'");
        }
        sb.append(" order by create_date desc ");
        return sb.toString();
    }


}
